Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grpc): patch loadPackageDefinition #400

Conversation

markwolff
Copy link
Member

Which problem is this PR solving?

Short description of the changes

The internal files loader is not correctly patching the internal generic catch all client.makeClientConstructor, so the 2 main ways of creating clients are patched instead. loadObject is not patched. I've disabled the generic patch until #285 solves the internal patches not propagating to the module's usage of them.

) {
const result = original.apply(this, arguments as never);
// Copied from exports.loadPackageDefintion(...)
for (const serviceFqn in packageDef) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to create a private function to do the code inside this for loop? That could help simplify the overall _patchLoadPackageDefinition function


shimmer.massWrap(
serviceClient.prototype,
methodList as never[],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: what's the role of the cast to never here?

);
endSpan();
// if an error was emitted, the span will be ended there
if (status.code === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a unit test for this?

@markwolff
Copy link
Member Author

Closing this since the change in patching is unnecessary if example is used outside of lerna #327

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gRPC plugin is not working correctly when loaded with @grpc/proto-loader
3 participants